package generalcheck;

import static org.junit.Assert.*;

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.LoadableComponent;

public class LoginPage extends LoadableComponent<LoginPage>{

	WebDriver driver;
	@FindBy(css="input[id='MUA_CODE.DUMMY.MENSYS']")
	WebElement username;
	
	@FindBy(css= "input[id='PASSWORD.DUMMY.MENSYS']")
	WebElement password;
	
	@FindBy(css="input[value='Log in']")
	WebElement loginButton;
	
	public void inputUserName(String username) {
		
		this.username.sendKeys(username);
		
	}
	public void inputPassword(String password) {
		
		this.password.sendKeys(password);
		
	}
	public void clickLoginButton(){
		
		loginButton.click();
	}
	
	public LoginPage(WebDriver driver){
		this.driver=driver;
		PageFactory.initElements(driver, this);
	}
	
	@Override
	  protected void load() {
	    driver.get("https://sys1.sydneystudent.sydney.edu.au/sitsvision/wrd/siw_lgn");
	  }

	  @Override
	  protected void isLoaded() throws Error {
	    String url = driver.getCurrentUrl();
	    assertTrue("Not on the issue entry page: " + url, url.endsWith("/siw_lgn"));
	  }
	public void close(){
		driver.quit();
	}
}
